<?php
/**
 * TomatoCMS
 * 
 * LICENSE
 *
 * This source file is subject to the GNU GENERAL PUBLIC LICENSE Version 2 
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://www.gnu.org/licenses/gpl-2.0.txt
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@tomatocms.com so we can send you a copy immediately.
 * 
 * @copyright	Copyright (c) 2009-2010 TIG Corporation (http://www.tig.vn)
 * @license		http://www.gnu.org/licenses/gpl-2.0.txt GNU GENERAL PUBLIC LICENSE Version 2
 * @version 	$Id: index.phtml 5069 2010-08-29 03:22:08Z huuphuoc $
 * @since		2.0.7
 */
?>
<?php 
$this->headTitle($this->translator('install_language_page_title'));

$this->headLink()->appendStylesheet($this->APP_STATIC_SERVER . '/js/jquery.uploadify/uploadify.css');

$this->headScript()
	->appendFile($this->APP_STATIC_SERVER . '/js/jquery.uploadify/jquery.uploadify.min.js')
	->appendFile($this->APP_STATIC_SERVER . '/js/swfobject/swfobject.js');
?>

<div class="t_a_install_step t_a_bottom">
	<div class="grid_12">
		<ul>
			<li class="t_a_install_step_active grid_3 alpha">
				<span>1</span>		
				<h2><?php echo $this->translator('install_steps_language'); ?></h2>
			</li>
			<li class="grid_3">
				<span>2</span>		
				<h2><?php echo $this->translator('install_steps_requirements'); ?></h2>
			</li>
			<li class="grid_3">
				<span>3</span>		
				<h2><?php echo $this->translator('install_steps_config'); ?></h2>
			</li>
			<li class="grid_3 omega">
				<span>4</span>
				<h2><?php echo $this->translator('install_steps_complete'); ?></h2>
			</li>
		</ul>
	</div>
</div>

<div class="t_a_install_container">
	<div class="prefix_1 grid_10 suffix_1">
	<form method="post" action="<?php echo $this->baseUrl(); ?>">
		<div class="clearfix t_a_bottom">
			<label><?php echo $this->translator('install_language_select_language'); ?>:</label>
			
			<select name="lang" id="lang" style="width: 150px">
				<?php foreach ($this->languages as $lang => $names) : ?>
				<option value="<?php echo $lang; ?>"<?php if ($this->lang == $lang): ?> selected="selected"<?php endif; ?>><?php echo $names['localName']; ?> (<?php echo $names['englishName']; ?>)</option>
				<?php endforeach; ?>
			</select>
		</div>
		
		<hr />
		
		<div class="clearfix t_a_bottom">
			<div class="grid_2 alpha">
				<label><?php echo $this->translator('install_language_or_upload_language'); ?>:</label>
			</div>
			<div class="grid_6 omega">
				<input type="file" name="uploadFile" id="uploadFile" style="width: 100px" />
			</div>
		</div>
		
		<hr />
		
		<div class="clearfix t_a_bottom">
			<label>&nbsp;</label>
			<button type="submit"><span><?php echo $this->translator('install_steps_next_button'); ?></span></button>
		</div>	
	</form>
	</div>
</div>

<script type="text/javascript">
$(document).ready(function() {
	/**
	 * Upload language package hanlder
	 */
	$('#uploadFile').uploadify({
		'scriptData': {
			act: 'upload'
		},
		'uploader': '<?php echo $this->APP_STATIC_SERVER; ?>/js/jquery.uploadify/uploadify.swf',
		'script': '<?php echo $this->url(array(), 'core_install_language'); ?>',
		'cancelImg': '<?php echo $this->APP_STATIC_SERVER; ?>/skins/admin/default/images/a_uploadify_cancel.png',
		'auto': true,
		'multi': false,
		'fileDesc': '*.zip',
		'fileExt': '*.zip',
		onComplete: function(event, ID, fileObj, response, data) {
			/**
			 * Append the uploaded language to languages selector
			 */
			var res = $.evalJSON(response);
			for (var i in res) {
				$('<option/>').val(i)
					.html(res[i].localName + '(' + res[i].englishName + ')')
					.attr('selected', 'selected')
					.appendTo($('#lang'));
			}
		}
	});
});
</script>
